home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / rcs / Setrcsstate < prev   
Encoding:
Text File  |  1994-08-02  |  3.0 KB  |  126 lines

  1. #! /bin/csh -f
  2. #
  3. # $Id: Setrcsstate,v 1.3 93/08/20 12:40:55 carlson Exp $
  4. #
  5. # Setrcsstate    Sets a name for a revision of every RCS file.
  6. #
  7. # Synopsis:
  8. #    Setrcsstate [-l] <name>
  9. #    Setrcsstate [-m] <name>:<rev>
  10. #
  11. # Description:
  12. #    This script sets the state for a revison of an RCS file.
  13. #
  14. #    In the first form, the state of the last branch is set to the
  15. #    name given.
  16. #
  17. #    In the second form, the specified revision is given the
  18. #    state.
  19. #
  20. # Parameters:
  21. #    -m        Set state only if revision exists.
  22. #    -l        Set the last state minus the last component.
  23. #
  24. # Revision History:
  25. #    $Log:    Setrcsstate,v $
  26. # Revision 1.3  93/08/20  12:40:55  carlson
  27. # Fix some comments.
  28. # If a symbolic revision doesn't exist, see if it is somewhere else in
  29. #   the log file.
  30. # Revision 1.3  1993/02/14  22:28:33  chris
  31. # Fixed some of the comments.
  32. # If a symbolic revision doesn't exist, see if it is somewhere else in
  33. #   the log file.
  34. #
  35. # Revision 1.2  92/10/22  11:33:09  chris
  36. # Check options only if there are parameters.
  37. # Revision 1.1  92/08/21  16:32:06  carlson
  38. # Initial revision
  39. #---------------------------------------------------------------------------
  40.  
  41. set name = ""
  42. set last = 0
  43. set override = 0
  44. set modify = 0
  45.  
  46. if ( $#argv >= 1 ) then
  47.     set argv = `getopt lm $*`
  48.     while ( "$1" != "--" )
  49.         switch ( $1 )
  50.           case "-l":
  51.         set last = 1
  52.         shift
  53.         breaksw
  54.  
  55.           case "-m":
  56.         set modify = 1
  57.         shift
  58.         breaksw
  59.         endsw
  60.     end
  61.     shift
  62. endif
  63.  
  64. if ( "$1" == "" ) then
  65.     echo "Usage: Setrcsstate <name>"
  66.     echo "       Setrcsstate <name>:<rev> [-m]"
  67.     echo "   -m = Set state only if revision exists."
  68.     exit
  69. endif
  70.  
  71. set name = $1
  72.  
  73. #----
  74. # rev = revision portion of name provided (everything after :)
  75. # name = name portion (everything before :)
  76. # Revc = revision preceded by colon
  77. #
  78. set rev = `echo $name | awk -F: '{ print $2 }'`
  79. set name = `echo $name | awk -F: '{ print $1 }'`
  80.  
  81. if ( "$rev" != "" ) then
  82.     set last = 0
  83.     set Revc = :$rev
  84. else
  85.     set modify = 0
  86. endif
  87.  
  88. #----
  89. # Loop through each RCS file found.  If there is an RCS directory,
  90. # loop through the files ending in ",v" in it.  Otherwise, loop
  91. # through files in the current directory ending in ",v".
  92. #
  93. set rcsdir = ""
  94. if ( -d RCS ) set rcsdir = "RCS/"
  95. foreach rcsfile ( `ls ${rcsdir}*,v` )
  96.     set file = `basename $rcsfile ,v`
  97.  
  98.     #----
  99.     # If we are supposed to set the last revision, get the last
  100.     # revision and remove the last component.
  101.     #
  102.     # If we are only to set the symbolic name if the revision exists,
  103.     # check if the revision exists and skip if not there.
  104.     #
  105.     if ( $last ) then
  106.     set rev = `rlog $file | grep "^head:" | awk '{print $NF}'`
  107.     set Rev = `echo $rev | awk -F. '{for(i=1;i<NF-1;i++)printf "%s.",$i;print $i}'`
  108.     set Revc = :$Rev
  109.     else if ( $modify ) then
  110.     set x = `rlog $file | grep "^revision $rev"`
  111.     if ( "$x" == "" ) then
  112.         set x = `rlog $file | grep "^symbolic.*$rev"`
  113.         if ( "$x" == "" ) continue
  114.     endif
  115.     endif
  116.  
  117.     rcs -s${name}${Revc} $file
  118. end
  119.  
  120. ### Local Variables:
  121. ### auto-fill-hook: nil
  122. ### End:
  123.